package ooday04;

public class Test1 {
    public static void main(String[] args) {
        /*
        Master1 master1=new Master1();
        Dog1 dog1=new Dog1("小黑",2,"黑");
        Fish1 fish1=new Fish1("小金",1,"金");
        Chick1 chick1=new Chick1("小花",3,"花");
        master1.feed(dog);
        master1.feed(fish);
        master1.feed(chick);

         */

        Animal1[] animal1s = new Animal1[5];
        animal1s[0] = new Dog1("x小黑", 2, "黑");
        animal1s[1] = new Dog1("小白", 3, "白");
        animal1s[2] = new Fish1("小金", 1, "金");
        animal1s[3] = new Fish1("小花", 2, "花");
        animal1s[4] = new Chick1("小灰", 3, "灰");
        for (int i = 0; i < animal1s.length; i++) {
            System.out.println(animal1s[i].color1);
            animal1s[i].eat();
            animal1s[i].drink();
            if (animal1s[i] instanceof Dog1) {
                Dog1 dog1 = (Dog1) animal1s[i];
                dog1.lookHome();
            }
            if (animal1s[i] instanceof Chick1) {
                Chick1 chick1 = (Chick1) animal1s[i];
                chick1.layEggs();
            }
            if (animal1s[i] instanceof Swim1) {
                Swim1 s = (Swim1) animal1s[i];
                s.swim1();
            }
        }


        /*
        Animal1 o=new Dog1("小黑",2,"黑");
        Dog1 d=(Dog1)o;
        Swim1 s=(Swim1)o;
        System.out.println(o instanceof Dog1);
        System.out.println(o instanceof Swim1);
        System.out.println(o instanceof Fish1);

         */
    }
}
